//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.erp.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import java.util.List;

public class PagedList<T> implements Serializable {
    private static final long serialVersionUID = 8160823395759291587L;
    private List<T> items;
    private int totalCount;
    private int currentPage;
    private int pageSize;

    public PagedList() {
    }

    public static <T> PagedList<T> createInstance(int pageNo, int pageSize, int totalCount, Class<T> t) {
        PagedList<T> pagedList = new PagedList();
        pagedList.setCurrentPage(pageNo);
        pagedList.setPageSize(pageSize);
        pagedList.setTotalCount(totalCount);
        return pagedList;
    }

    public List<T> getItems() {
        return this.items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }

    public int getTotalCount() {
        return this.totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    @JsonIgnore
    public int getFirstIndex() {
        return (this.getCurrentPage() - 1) * this.pageSize;
    }

    @JsonIgnore
    public boolean isValidPageNo() {
        long totalPage = 0L;
        if (this.totalCount % this.pageSize == 0) {
            totalPage = (long)(this.totalCount / this.pageSize);
        } else {
            totalPage = (long)(this.totalCount / this.pageSize + 1);
        }

        return this.getCurrentPage() >= 1 && (long)this.getCurrentPage() <= totalPage;
    }
}
